<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>隐藏文本框内容</title>
    <style>
        input{
            color: #999;
        }
    </style>
</head>
<body>
    <input type="text" value="手机">
    <script>
        var inp = document.querySelector('input')
        // 获得焦点 也就是光标
        inp.onfocus = function(){
            if(inp.value === '手机') {
                inp.value = ''
            }
            this.style.color='#333'
        }
        // 失去焦点 也就是鼠标点击了别处
        inp.onblur = function() {
            if(inp.value === '') {
                inp.value = '手机'
            }
            this.style.color='#999'
        }
    </script>
</body>
</html>